#ifndef MKAHYPAR_HYPERGRAPH_IO_H
#define MKAHYPAR_HYPERGRAPH_IO_H

#include <fstream>
#include <sstream>
#include <string>
#include <iostream>
#include "mkahypar/utils/typedef.h"
#include "mkahypar/partition/context.h"

namespace mkahypar {
  namespace io {
    //基于流的读
    static bool getNextLine(std::ifstream &file, std::string &line, size_t &line_number) {
      bool success = false;
      do {
        success = static_cast<bool>(std::getline(file, line));
        ++line_number;
        // skip any comments
      } while (success && line[0] == '%');
      return success;
    }



    //读取节点定义文件
    static void inline
    readDesignAre(const std::string &design_are, Hypergraph &hypergraph) {
      std::ifstream file(design_are);
      std::string line;
      size_t line_number = -1;
      while (getNextLine(file, line, line_number)) {

        std::stringstream ss(line);
        std::string node_name;
        ss >> node_name;
//        LLOG<<node_name;
        //建立映射
        Context::getInstance().nodeName2id[node_name] = line_number;
        Context::getInstance().id2nodeName[line_number] = node_name;
        NodeWeight  weight(8);
        for (int i = 0; i < 8; ++i) {
          ss >> weight[i];
//          LLOG<<weight[i];
        }
//        LOG<<"";
        //构建超点
        hypergraph.createHyperNode(weight);
      }

      file.close();

    }

    //读取超边文件


    //创建超图
    static inline void createHypergraphFromFile(const std::string &design_are,
                                                      const std::string &design_net,
                                                      const std::string &design_info,
                                                      const std::string &design_topo,
                                                      Hypergraph &hypergraph) {
      readDesignAre(design_are,hypergraph);

    }

    //输出订单

  }


}
#endif //MKAHYPAR_HYPERGRAPH_IO_H
